#include <cstdlib>
#include <string>
#include <iostream>
#include <set>
#include <vector>
using namespace std;


class Solution {
public:
	int minimumTotal(vector<vector<int> > &triangle) {
		int num = triangle.size();
		int *sums = new int[num];
		for (int i = 0; i < num; ++i){
			sums[i] = triangle[num - 1][i];
		}
		for (int i = num - 1; i != 0; i--){
			for (int j = 0; j < i; j++){
				// find min(sums[j], sums[j + 1]
				int min = sums[j] < sums[j + 1] ? sums[j] : sums[j + 1];
				triangle[i - 1][j] += min;
			}
			for (int j = 0; j < i; j++)
				sums[j] = triangle[i - 1][j];
		}
		return sums[0];
	}
};

int main(int argc, char** argv){
	
	Solution().getIntersectionNode(headA, headB);
	//cout << Solution().compareVersion("1.1.1", "1.1") << endl;
	return 0;
}